const origin = 'http://192.168.1.1:8001';

const reqOptions = {
    headers: {
        "x-requested-with": "XMLHttpRequest",
        "Access-Control-Allow-Origin": "*",
        "Content-Type": "application/json"
    },
}

const requestInterceptor = (u: any, o: any) => {
    const op = {
        ...o,
        ...reqOptions
    }
    const url = `${origin}${u}`

    return {
        url,
        op
    }
}

const requestError = (error: any) => {
    return Promise.reject(error)
}

export const request = {
    timeout: 3000,
    middlewares: [],
    requestInterceptors: [
        requestInterceptor,
        requestError,
    ],
    responseInterceptors: []
}